package cn.iocoder.yudao.module.bk.dal.dataobject.lwbook;

import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.bk.controller.admin.lwbookinapply.vo.BkImportExcelVO;
import cn.iocoder.yudao.module.bk.controller.app.vo.BookInfoReq;
import cn.iocoder.yudao.module.bk.dal.enm.BookStoreEnum;
import cn.iocoder.yudao.module.bk.dal.enm.LwProcessEnum;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 来往书籍 DO
 *
 * @author qy
 */
@TableName("bk_lw_book")
@KeySequence("bk_lw_book_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库，可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LwBookDO extends BaseDO {

    /**
     * 编号
     */
    @TableId
    private Long id;
    /**
     * 书名
     */
    private String title;
    /**
     * isbn编号
     */
    private String isbn;
    /**
     * 出版社
     */
    private String publisher;
    /**
     * 封面图
     */
    private String img;
    /**
     * 简介
     */
    private String summary;
    /**
     * 出版时间
     */
    private String pubDate;
    /**
     * 出版年限
     */
    private LocalDate pubYear;
    /**
     * 页数
     */
    private Integer pageCount;
    /**
     * 流程状态
     * <p>
     * 枚举 {@link TODO bk_book_apply_status 对应的类}
     */
    private String applyStatus;
    /**
     * 入库状态
     * <p>
     * 枚举 {@link TODO bk_book_store_status 对应的类}
     */
    private String storeStatus;
    /**
     * 入库时间
     */
    private LocalDateTime storeTime;
    /**
     * 捐献人id
     */
    private Long donor;
    /**
     * 捐献人名称
     */
    @TableField(exist = false)
    private String donorName;
    /**
     * 当前持有人id
     */
    private Long nowHolder;
    /**
     * 当前持有人名称
     */
    @TableField(exist = false)
    private String nowHolderName;
    /**
     * 备注
     */
    private String remark;

    /**
     * 合规出版社
     */
    @TableField(exist = false)
    private Boolean compliance;

    public LwBookDO(BookInfoReq book, Long uid, String applyStatus) {
        this.title = book.getTitle();
        this.isbn = book.getIsbn();
        this.publisher = book.getPublisher();
        this.pubDate = book.getPubDate();
        this.pageCount = book.getPageCount();
        //待审核
        this.applyStatus = applyStatus;
        //待入库
        this.storeStatus = BookStoreEnum.NO_STORE.getProcess();
        this.donor = uid;
        this.storeTime = LocalDateTime.now();

    }

    public LwBookDO(Long uid, BkImportExcelVO importExcelVO) {
        this.title = importExcelVO.getBookName();
        this.isbn = importExcelVO.getIsbn();
        //待审核
        this.applyStatus = LwProcessEnum.PASS.getProcess();
        //待入库
        this.storeStatus = BookStoreEnum.IN_STORE.getProcess();
        this.donor = uid;
        this.storeTime = importExcelVO.getSubmitTime();

    }

}
